import {
  findMemberById,
} from "@/api/after-sale/client/client";

export async function getUserDiscount (id) {
  let { data } = await findMemberById(id); //查询会员卡信息
  let obj = comeputDisconut(data); //折扣区间;
  return obj;
}
//计算折扣区间
function comeputDisconut (value) {
  let { hoursDiscount, partsDiscount } = value;
  let { projectDiscount, partsDiscount: partsDiscount2 } = JSON.parse(
    sessionStorage.getItem("login")
  );
  return {
    projectDiscount: comparisonSize(hoursDiscount, projectDiscount),
    partsDiscount: comparisonSize(partsDiscount, partsDiscount2),
  };
}
function comparisonSize (v1 = 10, v2 = 10) {
  return v1 >= v2 ? { max: v1 == 0 ? 10 : v1, min: v2 == 0 ? 10 : v2 } : { max: v2 == 0 ? 10 : v2, min: v1 == 0 ? 10 : v1 };
}